<!--
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-05-27 08:43:07
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-02 09:35:54
 * @FilePath: \linePatrol\vue-element-plus-admin\src\views\Authorization\User\components\Detail.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup lang="tsx">
import { PropType, h, computed } from 'vue'
import { ElImage, ElTag } from 'element-plus'
import { HandleDetails } from '@/api/scada/type'
import { usePatrolGroupStore } from '@/store/modules/PlanGroupStore'
const PATH_URL = import.meta.env.VITE_API_PHOTO_PATH
const GroupStore = usePatrolGroupStore()
const UserList = computed(() => {
  return GroupStore.getUserListAll
})
defineProps({
  currentRow: {
    type: Object as PropType<HandleDetails[]>,
    default: () => undefined
  }
})
const detailSchema: any = [
  {
    field: 'alertState',
    label: '状态',
    slots: {
      default: (data: any) => {
        if (data?.alertState == 1) {
          return h(ElTag, { type: 'primary' }, () => '已完成')
        } else {
          return h(ElTag, { type: 'danger' }, () => '未完成')
        }
      }
    }
  },
  {
    field: 'workUser',
    label: '处理人',
    slots: {
      default: (data: any) => {
        return UserList.value.map((item) => {
          if (item.userId == data?.workUser) {
            return item.userName
          }
        })
      }
    }
  },
  {
    field: 'workDes',
    label: '描述',
    span: 24
  },
  {
    field: 'fileImg',
    label: '上传图片',
    slots: {
      default: (data: any) => {
        const res = `${PATH_URL}${data?.fileImg}`
        return (
          <ElImage
            style="width: 70px; height: 70px;margin-left:10px"
            src={res}
            preview-src-list={res}
            fit="cover"
          />
        )
      }
    }
  }
]
</script>

<template>
  <div v-for="item in currentRow" :key="item.hanUuid">
    <Descriptions
      :title="'处理记录' + '---' + item?.createTime"
      :schema="detailSchema"
      :data="item"
    />
  </div>
</template>
